package advanced.practice._1009;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main_Obsolete {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

        int N=sc.nextInt();
        int M=sc.nextInt();
        int S=sc.nextInt();
        int D=sc.nextInt();

        List<City>cities=new ArrayList<>();
        for(int i=0;i<N;i++){
            cities.add(i,new City(i));
        }

        for(int i=0;i<M;i++){
            City from=cities.get(sc.nextInt());
            City to=cities.get(sc.nextInt());
            int dis=sc.nextInt();
            int cost=sc.nextInt();
//            HighWay highWay=new HighWay(from,to,dis,cost);
            from.ways.add(new HighWay(from,to,dis,cost));
            to.ways.add(new HighWay(to,from,dis,cost));
        }

        Route route=findRoute(cities,cities.get(S),cities.get(D));
        for(City c:route.cities){
            System.out.print(c.id+" ");
        }
        System.out.println(route.totalDistance+" "+route.totalCost);
    }

    static Route findRoute(List<City>cities,City from,City to){
        if(from==to){
            return new Route();
        }

        List<HighWay> ways=from.ways;

        int len=ways.size();

        List <Route>routes=new ArrayList<>();

        for (int i = 0; i < len; i++) {
            Route route=new Route();
            route.cities.add(ways.get(i).city1);
            route.cities.add(ways.get(i).city2);
            route.totalCost=ways.get(i).cost;
            route.totalDistance=ways.get(i).distance;

            List<City>subCities=new ArrayList<>();
            for(City c:cities){
                City city=new City(c.id);
//                HighWay[]hs=( HighWay[])c.ways.toArray();
                for(HighWay hw:c.ways){
                    if(hw.city1.id==from.id||hw.city2.id==from.id){
                        continue;
                    }
                    city.ways.add(hw);
                }
                subCities.add(city);
            }

            route.addRoute(findRoute(subCities,ways.get(i).city2,to));

            routes.add(route);
        }
        Collections.sort(routes);

        return routes.get(0);
    }

    static class Route implements Comparable<Route>{
        List<City>cities=new ArrayList<>();
        int totalCost=0;
        int totalDistance=0;

        boolean addRoute(Route other){
            if(other.cities.isEmpty()||(!cities.isEmpty()&&cities.get(cities.size()-1).id!=other.cities.get(0).id)){
                return false;
            }
            for(int i=1;i<other.cities.size();i++){
                cities.add(other.cities.get(i));
            }
            totalCost+=other.totalCost;
            totalDistance+=other.totalDistance;
            return true;
        }
        @Override
        public int compareTo(Route o) {
            int dis=totalDistance-o.totalDistance;
            return dis==0?totalCost-o.totalCost:dis;
        }
    }

    static class City{
        int id;
        List<HighWay> ways=new ArrayList<>();

        public City(int id) {
            this.id = id;
        }
    }
    static class HighWay{
        City city1;
        City city2;
        int distance;
        int cost;

        public HighWay(City city1, City city2, int distance, int cost) {
            this.city1 = city1;
            this.city2 = city2;
            this.distance = distance;
            this.cost = cost;
        }
    }
}
